<!doctype html>
<?php
    session_start();
	$username=$_SESSION['username'];
	include("conn.php");	
?>

<html>
<head>
 <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>我的收藏</title>
    <link rel="stylesheet" href="css/common.css" />
    <link rel="stylesheet" href="css/header.css" />
    <link rel="stylesheet" href="css/goodsList.css" />
	<link rel="stylesheet" href="css/mycar.css" />
</head>

<body>
  <header>
        <div id="head-top" style="margin-top: 5px;">
            <nav class="clearfix">

		  <div class="location" style="">
       <span>地区 ： </span>
      <i class="cd-location">&nbsp;<input type="text" class="selectBoxPub_r flightto" style="border:none;width:50px;background-color:#e6e3e6; font-size: 12px;"></i>
</div>	
				  
				  
				  
				  
                <ul class="right clearfix">
                 <li class="menu welcome">
                       <?php
						if(!empty($_SESSION['identity'])){
                       echo "<a href='index.php' class='link-login'>主页</a>";}
						
					else{
							echo "<a href='login.php' class='link-login'>你好，请登录</a>";
						}
						
						?>
                        
                    </li>
                    <li class="spacer">|</li>
                    <li class="menu red"><a href="myorder.html" style="color:#999">加入我们</a></li>
                    <li class="spacer">|</li>
                    <li class="menu red">
                    <?php
					if(!empty($_SESSION['identity'])){
                    echo "<a href='myorder.php'>我的订单&nbsp;∨</a>";}
					else{
						 "<a href='#'>我的订单&nbsp;∨</a>";
					}
                    ?>
                    </li>
                    <li class="spacer">|</li>
                    <li class="menu red">企业合作</li>
                    <li class="spacer">|</li>
                    <li class="menu qiye">餐饮采购&nbsp;∨</li>
                    <li class="spacer">|</li>

                </ul>
            </nav>
        </div>
        <div class="w clearfix">
            <div id="logo">
                <a href="index.html"><img src="img/logo.png" ></a>
            </div>
            <div id="search">
                <!-- 搜索列表  已隐藏 -->
                <ul class="menu" id="shelper"></ul>
                <div class="form">
                    <input type="text" id="key" value="水果" class="text blurcolor">
                    <i class="fa fa-camera"></i>
                    <button>搜索</button>
                </div>
            </div>
            <div id="settleup" class="dropdown">
                <div class="cw-icon">
                    <i class="fa fa-shopping-cart car"></i>
                    <i class="i-count" id="count">0</i>
                    <a href="gwc.php">我的购物车</a>
                </div>
                
            </div>
            
        </div>
    </header>
    <section>
        <div id="nav">
            <div class="w clearfix">
                <div id="categorys" style="height: auto; left: 0px; position: absolute;">
                    <div class="dt">
                        <a href="collection.php">我的收藏</a>
                    </div>
                    <div class="dd" style="display: none;"></div>										
                </div>
                <div id="navitems" class="clearfix">
                    <ul class="navitems-group1 clearfix">
                        <li><a href="myorder.php">我的订单</a></li>
                        <li><a href="users.php">我的信息</a></li>
                        <li><a href="#">遇到问题？</a></li>
                    </ul>
  
                </div>
            </div>
        </div>
		        
        
		<div class="inf">
		
		<h2 style="text-align: center">  我的收藏  </h2> 
		<br><br>
		<center>
            

            
            
            <table width="900" border="1" cellpadding="0" cellspacing="0" style="table-layout: fixed;border-collapse: collapse">
                <tr style="background:#E6E6FA;height: 35px">
    
                    <th width="15%">商品名字</th>      
					<th width="12%">价格</th>
                    <th width="12%">店铺</th>
                    <th width="30%">操作</th>
                </tr>
                    
                   
              <?php
	$sql = "select *from collection where username='$username'";
	$result = mysqli_query($conn,$sql);	
	if(!empty($result)){
	while ($row = mysqli_fetch_row($result))
	{	
		           echo  "<tr align='center' style='height: 30px'>";
                   echo "<td width='15%'>".$row[1]."</td>";
				   echo "<td width='12%'>".$row[2]."</td>";
				   echo "<td width='5%'>".$row[0]."</td>";
                   echo  "<td width='12%' style='background:#ffffcc'>";
                   echo       "<a href=gwcgo.php?goodsname=" . $row[1]. '&price=' . $row[2]. '&picture=' . $row[4]."> 加入购物车/ </a>";     
				   echo	      "<a href=collectioncut.php?goodsname=" . $row[1] . '&price=' . $row[2] ."> 删除此商品 </a></td>";
						  
					echo  "</td>";
		           echo   "</tr>";
					   
	}}
	else{
			 echo "<script language=javascript>alert('您还没有收藏商品');location='javascript:history.go(-1)'</script>";
		}
	   ?>
               
                
         
               
            </table>
        </center>
        
  </div>
</body>
</html>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=eFaNjhaFcBEWaqwqs3N5ziq4PKUClOiY"></script>
 <script>
			var isLocate = false; //判断是否定位

			var flightto = document.querySelector(".flightto");
			//获取地理位置定位
			function locateMe() {
				var geolocation = new BMap.Geolocation();
				geolocation.getCurrentPosition(function(r) {
					if(this.getStatus() == BMAP_STATUS_SUCCESS) {
						isLocate = true;
						var url = "http://api.map.baidu.com/geocoder/v2/" +
							"?callback=renderReverse&location=" + r.point.lat + "," + r.point.lng + "&output=json&pois=1&ak=eFaNjhaFcBEWaqwqs3N5ziq4PKUClOiY";
						var JSONP = document.createElement("script");
						JSONP.src = url;
						document.body.appendChild(JSONP);
					} else {
						alert('failed' + this.getStatus());
					}
				}, {
					enableHighAccuracy: true
				})
			}
			locateMe();

			function renderReverse(r) {
				flightto.value = r.result.addressComponent.city;
				console.log(r);
			}
		</script>
